// $ANTLR 3.2 Sep 23, 2009 12:02:23 C:\\NCql\\NCql.Parser\\NCql.g 2009-11-04 14:19:20


using System;
using Antlr.Runtime;
using IList 		= System.Collections.IList;
using ArrayList 	= System.Collections.ArrayList;
using Stack 		= Antlr.Runtime.Collections.StackList;



using Antlr.Runtime.Tree;

public class NCqlParser : Parser 
{
    public static readonly string[] tokenNames = new string[] 
	{
        "<invalid>", 
		"<EOR>", 
		"<DOWN>", 
		"<UP>", 
		"CHARSTRING1", 
		"CHARSTRING2", 
		"STRINGCHAR", 
		"EQUAL", 
		"UNICODECHAR", 
		"ESCAPESEQUENCE", 
		"PREFIX", 
		"SEARCHCLAUSE", 
		"NULL", 
		"SERVERCHOICE", 
		"SORTEDQUERY", 
		"SINGLESPEC", 
		"MODIFIERLIST", 
		"MODIFIER", 
		"PREFIXASSIGNMENTS", 
		"SORTCRITERIA", 
		"'sortby'", 
		"'>'", 
		"'and'", 
		"'or'", 
		"'not'", 
		"'prox'", 
		"'('", 
		"')'", 
		"'<'", 
		"'>='", 
		"'<='", 
		"'<>'", 
		"'=='", 
		"'/'"
    };

    public const int PREFIX = 10;
    public const int T__29 = 29;
    public const int T__28 = 28;
    public const int T__27 = 27;
    public const int T__26 = 26;
    public const int PREFIXASSIGNMENTS = 18;
    public const int T__25 = 25;
    public const int T__24 = 24;
    public const int T__23 = 23;
    public const int T__22 = 22;
    public const int T__21 = 21;
    public const int NULL = 12;
    public const int T__20 = 20;
    public const int STRINGCHAR = 6;
    public const int SORTEDQUERY = 14;
    public const int EOF = -1;
    public const int MODIFIER = 17;
    public const int MODIFIERLIST = 16;
    public const int T__30 = 30;
    public const int SERVERCHOICE = 13;
    public const int T__31 = 31;
    public const int T__32 = 32;
    public const int T__33 = 33;
    public const int ESCAPESEQUENCE = 9;
    public const int SEARCHCLAUSE = 11;
    public const int SORTCRITERIA = 19;
    public const int EQUAL = 7;
    public const int UNICODECHAR = 8;
    public const int CHARSTRING1 = 4;
    public const int CHARSTRING2 = 5;
    public const int SINGLESPEC = 15;

    // delegates
    // delegators



        public NCqlParser(ITokenStream input)
    		: this(input, new RecognizerSharedState()) {
        }

        public NCqlParser(ITokenStream input, RecognizerSharedState state)
    		: base(input, state) {
            InitializeCyclicDFAs();

             
       }
        
    protected ITreeAdaptor adaptor = new CommonTreeAdaptor();

    public ITreeAdaptor TreeAdaptor
    {
        get { return this.adaptor; }
        set {
    	this.adaptor = value;
    	}
    }

    override public string[] TokenNames {
		get { return NCqlParser.tokenNames; }
    }

    override public string GrammarFileName {
		get { return "C:\\NCql\\NCql.Parser\\NCql.g"; }
    }


    ArrayList exceptions = new ArrayList();

    public override void ReportError(RecognitionException e)
    {
        exceptions.Add(e);
    }

    public bool HasError
    {
    	get { return exceptions.Count > 0; }
    }

    public string ErrorMessage
    {
    	get { return this.GetErrorMessage(exceptions[0] as RecognitionException, this.TokenNames); }
    }

    public string ErrorPosition
    {
    	get { return this.GetErrorHeader(exceptions[0] as RecognitionException); }
    }


    public class q_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "q"
    // C:\\NCql\\NCql.Parser\\NCql.g:36:1: q : sortedQuery EOF -> sortedQuery ;
    public NCqlParser.q_return q() // throws RecognitionException [1]
    {   
        NCqlParser.q_return retval = new NCqlParser.q_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken EOF2 = null;
        NCqlParser.sortedQuery_return sortedQuery1 = null;


        CommonTree EOF2_tree=null;
        RewriteRuleTokenStream stream_EOF = new RewriteRuleTokenStream(adaptor,"token EOF");
        RewriteRuleSubtreeStream stream_sortedQuery = new RewriteRuleSubtreeStream(adaptor,"rule sortedQuery");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:36:3: ( sortedQuery EOF -> sortedQuery )
            // C:\\NCql\\NCql.Parser\\NCql.g:37:2: sortedQuery EOF
            {
            	PushFollow(FOLLOW_sortedQuery_in_q42);
            	sortedQuery1 = sortedQuery();
            	state.followingStackPointer--;

            	stream_sortedQuery.Add(sortedQuery1.Tree);
            	EOF2=(IToken)Match(input,EOF,FOLLOW_EOF_in_q44);  
            	stream_EOF.Add(EOF2);



            	// AST REWRITE
            	// elements:          sortedQuery
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 37:18: -> sortedQuery
            	{
            	    adaptor.AddChild(root_0, stream_sortedQuery.NextTree());

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "q"

    public class sortedQuery_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "sortedQuery"
    // C:\\NCql\\NCql.Parser\\NCql.g:39:1: sortedQuery : ( prefixAssignment )* scopedClause ( 'sortby' sortSpec )? -> ^( SORTEDQUERY scopedClause ( ^( SORTCRITERIA sortSpec ) )? ^( PREFIXASSIGNMENTS ( prefixAssignment )* ) ) ;
    public NCqlParser.sortedQuery_return sortedQuery() // throws RecognitionException [1]
    {   
        NCqlParser.sortedQuery_return retval = new NCqlParser.sortedQuery_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken string_literal5 = null;
        NCqlParser.prefixAssignment_return prefixAssignment3 = null;

        NCqlParser.scopedClause_return scopedClause4 = null;

        NCqlParser.sortSpec_return sortSpec6 = null;


        CommonTree string_literal5_tree=null;
        RewriteRuleTokenStream stream_20 = new RewriteRuleTokenStream(adaptor,"token 20");
        RewriteRuleSubtreeStream stream_prefixAssignment = new RewriteRuleSubtreeStream(adaptor,"rule prefixAssignment");
        RewriteRuleSubtreeStream stream_scopedClause = new RewriteRuleSubtreeStream(adaptor,"rule scopedClause");
        RewriteRuleSubtreeStream stream_sortSpec = new RewriteRuleSubtreeStream(adaptor,"rule sortSpec");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:40:2: ( ( prefixAssignment )* scopedClause ( 'sortby' sortSpec )? -> ^( SORTEDQUERY scopedClause ( ^( SORTCRITERIA sortSpec ) )? ^( PREFIXASSIGNMENTS ( prefixAssignment )* ) ) )
            // C:\\NCql\\NCql.Parser\\NCql.g:41:2: ( prefixAssignment )* scopedClause ( 'sortby' sortSpec )?
            {
            	// C:\\NCql\\NCql.Parser\\NCql.g:41:2: ( prefixAssignment )*
            	do 
            	{
            	    int alt1 = 2;
            	    int LA1_0 = input.LA(1);

            	    if ( (LA1_0 == 21) )
            	    {
            	        alt1 = 1;
            	    }


            	    switch (alt1) 
            		{
            			case 1 :
            			    // C:\\NCql\\NCql.Parser\\NCql.g:41:2: prefixAssignment
            			    {
            			    	PushFollow(FOLLOW_prefixAssignment_in_sortedQuery60);
            			    	prefixAssignment3 = prefixAssignment();
            			    	state.followingStackPointer--;

            			    	stream_prefixAssignment.Add(prefixAssignment3.Tree);

            			    }
            			    break;

            			default:
            			    goto loop1;
            	    }
            	} while (true);

            	loop1:
            		;	// Stops C# compiler whining that label 'loop1' has no statements

            	PushFollow(FOLLOW_scopedClause_in_sortedQuery63);
            	scopedClause4 = scopedClause();
            	state.followingStackPointer--;

            	stream_scopedClause.Add(scopedClause4.Tree);
            	// C:\\NCql\\NCql.Parser\\NCql.g:41:33: ( 'sortby' sortSpec )?
            	int alt2 = 2;
            	int LA2_0 = input.LA(1);

            	if ( (LA2_0 == 20) )
            	{
            	    alt2 = 1;
            	}
            	switch (alt2) 
            	{
            	    case 1 :
            	        // C:\\NCql\\NCql.Parser\\NCql.g:41:34: 'sortby' sortSpec
            	        {
            	        	string_literal5=(IToken)Match(input,20,FOLLOW_20_in_sortedQuery66);  
            	        	stream_20.Add(string_literal5);

            	        	PushFollow(FOLLOW_sortSpec_in_sortedQuery68);
            	        	sortSpec6 = sortSpec();
            	        	state.followingStackPointer--;

            	        	stream_sortSpec.Add(sortSpec6.Tree);

            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          prefixAssignment, sortSpec, scopedClause
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 41:54: -> ^( SORTEDQUERY scopedClause ( ^( SORTCRITERIA sortSpec ) )? ^( PREFIXASSIGNMENTS ( prefixAssignment )* ) )
            	{
            	    // C:\\NCql\\NCql.Parser\\NCql.g:41:57: ^( SORTEDQUERY scopedClause ( ^( SORTCRITERIA sortSpec ) )? ^( PREFIXASSIGNMENTS ( prefixAssignment )* ) )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SORTEDQUERY, "SORTEDQUERY"), root_1);

            	    adaptor.AddChild(root_1, stream_scopedClause.NextTree());
            	    // C:\\NCql\\NCql.Parser\\NCql.g:41:84: ( ^( SORTCRITERIA sortSpec ) )?
            	    if ( stream_sortSpec.HasNext() )
            	    {
            	        // C:\\NCql\\NCql.Parser\\NCql.g:41:84: ^( SORTCRITERIA sortSpec )
            	        {
            	        CommonTree root_2 = (CommonTree)adaptor.GetNilNode();
            	        root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SORTCRITERIA, "SORTCRITERIA"), root_2);

            	        adaptor.AddChild(root_2, stream_sortSpec.NextTree());

            	        adaptor.AddChild(root_1, root_2);
            	        }

            	    }
            	    stream_sortSpec.Reset();
            	    // C:\\NCql\\NCql.Parser\\NCql.g:41:110: ^( PREFIXASSIGNMENTS ( prefixAssignment )* )
            	    {
            	    CommonTree root_2 = (CommonTree)adaptor.GetNilNode();
            	    root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PREFIXASSIGNMENTS, "PREFIXASSIGNMENTS"), root_2);

            	    // C:\\NCql\\NCql.Parser\\NCql.g:41:130: ( prefixAssignment )*
            	    while ( stream_prefixAssignment.HasNext() )
            	    {
            	        adaptor.AddChild(root_2, stream_prefixAssignment.NextTree());

            	    }
            	    stream_prefixAssignment.Reset();

            	    adaptor.AddChild(root_1, root_2);
            	    }

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "sortedQuery"

    public class sortSpec_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "sortSpec"
    // C:\\NCql\\NCql.Parser\\NCql.g:44:1: sortSpec : ( singleSpec )+ ;
    public NCqlParser.sortSpec_return sortSpec() // throws RecognitionException [1]
    {   
        NCqlParser.sortSpec_return retval = new NCqlParser.sortSpec_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.singleSpec_return singleSpec7 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:44:9: ( ( singleSpec )+ )
            // C:\\NCql\\NCql.Parser\\NCql.g:45:2: ( singleSpec )+
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	// C:\\NCql\\NCql.Parser\\NCql.g:45:2: ( singleSpec )+
            	int cnt3 = 0;
            	do 
            	{
            	    int alt3 = 2;
            	    int LA3_0 = input.LA(1);

            	    if ( ((LA3_0 >= CHARSTRING1 && LA3_0 <= CHARSTRING2) || LA3_0 == 20 || (LA3_0 >= 22 && LA3_0 <= 25)) )
            	    {
            	        alt3 = 1;
            	    }


            	    switch (alt3) 
            		{
            			case 1 :
            			    // C:\\NCql\\NCql.Parser\\NCql.g:45:3: singleSpec
            			    {
            			    	PushFollow(FOLLOW_singleSpec_in_sortSpec106);
            			    	singleSpec7 = singleSpec();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, singleSpec7.Tree);

            			    }
            			    break;

            			default:
            			    if ( cnt3 >= 1 ) goto loop3;
            		            EarlyExitException eee3 =
            		                new EarlyExitException(3, input);
            		            throw eee3;
            	    }
            	    cnt3++;
            	} while (true);

            	loop3:
            		;	// Stops C# compiler whining that label 'loop3' has no statements


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "sortSpec"

    public class singleSpec_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "singleSpec"
    // C:\\NCql\\NCql.Parser\\NCql.g:47:1: singleSpec : index ( modifierList )? -> ^( SINGLESPEC index ( modifierList )? ) ;
    public NCqlParser.singleSpec_return singleSpec() // throws RecognitionException [1]
    {   
        NCqlParser.singleSpec_return retval = new NCqlParser.singleSpec_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.index_return index8 = null;

        NCqlParser.modifierList_return modifierList9 = null;


        RewriteRuleSubtreeStream stream_index = new RewriteRuleSubtreeStream(adaptor,"rule index");
        RewriteRuleSubtreeStream stream_modifierList = new RewriteRuleSubtreeStream(adaptor,"rule modifierList");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:47:11: ( index ( modifierList )? -> ^( SINGLESPEC index ( modifierList )? ) )
            // C:\\NCql\\NCql.Parser\\NCql.g:47:13: index ( modifierList )?
            {
            	PushFollow(FOLLOW_index_in_singleSpec116);
            	index8 = index();
            	state.followingStackPointer--;

            	stream_index.Add(index8.Tree);
            	// C:\\NCql\\NCql.Parser\\NCql.g:47:19: ( modifierList )?
            	int alt4 = 2;
            	int LA4_0 = input.LA(1);

            	if ( (LA4_0 == 33) )
            	{
            	    alt4 = 1;
            	}
            	switch (alt4) 
            	{
            	    case 1 :
            	        // C:\\NCql\\NCql.Parser\\NCql.g:47:19: modifierList
            	        {
            	        	PushFollow(FOLLOW_modifierList_in_singleSpec118);
            	        	modifierList9 = modifierList();
            	        	state.followingStackPointer--;

            	        	stream_modifierList.Add(modifierList9.Tree);

            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          modifierList, index
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 47:33: -> ^( SINGLESPEC index ( modifierList )? )
            	{
            	    // C:\\NCql\\NCql.Parser\\NCql.g:47:36: ^( SINGLESPEC index ( modifierList )? )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SINGLESPEC, "SINGLESPEC"), root_1);

            	    adaptor.AddChild(root_1, stream_index.NextTree());
            	    // C:\\NCql\\NCql.Parser\\NCql.g:47:55: ( modifierList )?
            	    if ( stream_modifierList.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_modifierList.NextTree());

            	    }
            	    stream_modifierList.Reset();

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "singleSpec"

    public class cqlQuery_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "cqlQuery"
    // C:\\NCql\\NCql.Parser\\NCql.g:50:1: cqlQuery : ( prefixAssignment cqlQuery | scopedClause );
    public NCqlParser.cqlQuery_return cqlQuery() // throws RecognitionException [1]
    {   
        NCqlParser.cqlQuery_return retval = new NCqlParser.cqlQuery_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.prefixAssignment_return prefixAssignment10 = null;

        NCqlParser.cqlQuery_return cqlQuery11 = null;

        NCqlParser.scopedClause_return scopedClause12 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:50:9: ( prefixAssignment cqlQuery | scopedClause )
            int alt5 = 2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0 == 21) )
            {
                alt5 = 1;
            }
            else if ( ((LA5_0 >= CHARSTRING1 && LA5_0 <= CHARSTRING2) || LA5_0 == 20 || (LA5_0 >= 22 && LA5_0 <= 26)) )
            {
                alt5 = 2;
            }
            else 
            {
                NoViableAltException nvae_d5s0 =
                    new NoViableAltException("", 5, 0, input);

                throw nvae_d5s0;
            }
            switch (alt5) 
            {
                case 1 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:51:2: prefixAssignment cqlQuery
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_prefixAssignment_in_cqlQuery142);
                    	prefixAssignment10 = prefixAssignment();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, prefixAssignment10.Tree);
                    	PushFollow(FOLLOW_cqlQuery_in_cqlQuery144);
                    	cqlQuery11 = cqlQuery();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, cqlQuery11.Tree);

                    }
                    break;
                case 2 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:52:4: scopedClause
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_scopedClause_in_cqlQuery150);
                    	scopedClause12 = scopedClause();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, scopedClause12.Tree);

                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "cqlQuery"

    public class prefixAssignment_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "prefixAssignment"
    // C:\\NCql\\NCql.Parser\\NCql.g:55:1: prefixAssignment : ( '>' prefix '=' uri -> ^( PREFIX uri prefix ) | '>' uri -> ^( PREFIX uri ) );
    public NCqlParser.prefixAssignment_return prefixAssignment() // throws RecognitionException [1]
    {   
        NCqlParser.prefixAssignment_return retval = new NCqlParser.prefixAssignment_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken char_literal13 = null;
        IToken char_literal15 = null;
        IToken char_literal17 = null;
        NCqlParser.prefix_return prefix14 = null;

        NCqlParser.uri_return uri16 = null;

        NCqlParser.uri_return uri18 = null;


        CommonTree char_literal13_tree=null;
        CommonTree char_literal15_tree=null;
        CommonTree char_literal17_tree=null;
        RewriteRuleTokenStream stream_21 = new RewriteRuleTokenStream(adaptor,"token 21");
        RewriteRuleTokenStream stream_EQUAL = new RewriteRuleTokenStream(adaptor,"token EQUAL");
        RewriteRuleSubtreeStream stream_prefix = new RewriteRuleSubtreeStream(adaptor,"rule prefix");
        RewriteRuleSubtreeStream stream_uri = new RewriteRuleSubtreeStream(adaptor,"rule uri");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:55:17: ( '>' prefix '=' uri -> ^( PREFIX uri prefix ) | '>' uri -> ^( PREFIX uri ) )
            int alt6 = 2;
            alt6 = dfa6.Predict(input);
            switch (alt6) 
            {
                case 1 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:56:3: '>' prefix '=' uri
                    {
                    	char_literal13=(IToken)Match(input,21,FOLLOW_21_in_prefixAssignment161);  
                    	stream_21.Add(char_literal13);

                    	PushFollow(FOLLOW_prefix_in_prefixAssignment163);
                    	prefix14 = prefix();
                    	state.followingStackPointer--;

                    	stream_prefix.Add(prefix14.Tree);
                    	char_literal15=(IToken)Match(input,EQUAL,FOLLOW_EQUAL_in_prefixAssignment165);  
                    	stream_EQUAL.Add(char_literal15);

                    	PushFollow(FOLLOW_uri_in_prefixAssignment167);
                    	uri16 = uri();
                    	state.followingStackPointer--;

                    	stream_uri.Add(uri16.Tree);


                    	// AST REWRITE
                    	// elements:          prefix, uri
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 56:22: -> ^( PREFIX uri prefix )
                    	{
                    	    // C:\\NCql\\NCql.Parser\\NCql.g:56:25: ^( PREFIX uri prefix )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PREFIX, "PREFIX"), root_1);

                    	    adaptor.AddChild(root_1, stream_uri.NextTree());
                    	    adaptor.AddChild(root_1, stream_prefix.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;
                case 2 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:57:3: '>' uri
                    {
                    	char_literal17=(IToken)Match(input,21,FOLLOW_21_in_prefixAssignment183);  
                    	stream_21.Add(char_literal17);

                    	PushFollow(FOLLOW_uri_in_prefixAssignment185);
                    	uri18 = uri();
                    	state.followingStackPointer--;

                    	stream_uri.Add(uri18.Tree);


                    	// AST REWRITE
                    	// elements:          uri
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 57:11: -> ^( PREFIX uri )
                    	{
                    	    // C:\\NCql\\NCql.Parser\\NCql.g:57:14: ^( PREFIX uri )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PREFIX, "PREFIX"), root_1);

                    	    adaptor.AddChild(root_1, stream_uri.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "prefixAssignment"

    public class scopedClause_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "scopedClause"
    // C:\\NCql\\NCql.Parser\\NCql.g:61:1: scopedClause : searchClause ( booleanGroup searchClause )* ;
    public NCqlParser.scopedClause_return scopedClause() // throws RecognitionException [1]
    {   
        NCqlParser.scopedClause_return retval = new NCqlParser.scopedClause_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.searchClause_return searchClause19 = null;

        NCqlParser.booleanGroup_return booleanGroup20 = null;

        NCqlParser.searchClause_return searchClause21 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:61:13: ( searchClause ( booleanGroup searchClause )* )
            // C:\\NCql\\NCql.Parser\\NCql.g:62:3: searchClause ( booleanGroup searchClause )*
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_searchClause_in_scopedClause206);
            	searchClause19 = searchClause();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, searchClause19.Tree);
            	// C:\\NCql\\NCql.Parser\\NCql.g:62:16: ( booleanGroup searchClause )*
            	do 
            	{
            	    int alt7 = 2;
            	    int LA7_0 = input.LA(1);

            	    if ( ((LA7_0 >= 22 && LA7_0 <= 25)) )
            	    {
            	        alt7 = 1;
            	    }


            	    switch (alt7) 
            		{
            			case 1 :
            			    // C:\\NCql\\NCql.Parser\\NCql.g:62:17: booleanGroup searchClause
            			    {
            			    	PushFollow(FOLLOW_booleanGroup_in_scopedClause209);
            			    	booleanGroup20 = booleanGroup();
            			    	state.followingStackPointer--;

            			    	root_0 = (CommonTree)adaptor.BecomeRoot(booleanGroup20.Tree, root_0);
            			    	PushFollow(FOLLOW_searchClause_in_scopedClause212);
            			    	searchClause21 = searchClause();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, searchClause21.Tree);

            			    }
            			    break;

            			default:
            			    goto loop7;
            	    }
            	} while (true);

            	loop7:
            		;	// Stops C# compiler whining that label 'loop7' has no statements


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "scopedClause"

    public class booleanGroup_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "booleanGroup"
    // C:\\NCql\\NCql.Parser\\NCql.g:64:1: booleanGroup : boolean ( modifierList )? -> ^( boolean ( modifierList )? ) ;
    public NCqlParser.booleanGroup_return booleanGroup() // throws RecognitionException [1]
    {   
        NCqlParser.booleanGroup_return retval = new NCqlParser.booleanGroup_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.boolean_return boolean22 = null;

        NCqlParser.modifierList_return modifierList23 = null;


        RewriteRuleSubtreeStream stream_modifierList = new RewriteRuleSubtreeStream(adaptor,"rule modifierList");
        RewriteRuleSubtreeStream stream_boolean = new RewriteRuleSubtreeStream(adaptor,"rule boolean");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:64:13: ( boolean ( modifierList )? -> ^( boolean ( modifierList )? ) )
            // C:\\NCql\\NCql.Parser\\NCql.g:65:3: boolean ( modifierList )?
            {
            	PushFollow(FOLLOW_boolean_in_booleanGroup223);
            	boolean22 = boolean();
            	state.followingStackPointer--;

            	stream_boolean.Add(boolean22.Tree);
            	// C:\\NCql\\NCql.Parser\\NCql.g:65:11: ( modifierList )?
            	int alt8 = 2;
            	int LA8_0 = input.LA(1);

            	if ( (LA8_0 == 33) )
            	{
            	    alt8 = 1;
            	}
            	switch (alt8) 
            	{
            	    case 1 :
            	        // C:\\NCql\\NCql.Parser\\NCql.g:65:12: modifierList
            	        {
            	        	PushFollow(FOLLOW_modifierList_in_booleanGroup226);
            	        	modifierList23 = modifierList();
            	        	state.followingStackPointer--;

            	        	stream_modifierList.Add(modifierList23.Tree);

            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          modifierList, boolean
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 65:27: -> ^( boolean ( modifierList )? )
            	{
            	    // C:\\NCql\\NCql.Parser\\NCql.g:65:30: ^( boolean ( modifierList )? )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot(stream_boolean.NextNode(), root_1);

            	    // C:\\NCql\\NCql.Parser\\NCql.g:65:40: ( modifierList )?
            	    if ( stream_modifierList.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_modifierList.NextTree());

            	    }
            	    stream_modifierList.Reset();

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "booleanGroup"

    public class boolean_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "boolean"
    // C:\\NCql\\NCql.Parser\\NCql.g:67:1: boolean : ( 'and' | 'or' | 'not' | 'prox' );
    public NCqlParser.boolean_return boolean() // throws RecognitionException [1]
    {   
        NCqlParser.boolean_return retval = new NCqlParser.boolean_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken set24 = null;

        CommonTree set24_tree=null;

        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:67:8: ( 'and' | 'or' | 'not' | 'prox' )
            // C:\\NCql\\NCql.Parser\\NCql.g:
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	set24 = (IToken)input.LT(1);
            	if ( (input.LA(1) >= 22 && input.LA(1) <= 25) ) 
            	{
            	    input.Consume();
            	    adaptor.AddChild(root_0, (CommonTree)adaptor.Create(set24));
            	    state.errorRecovery = false;
            	}
            	else 
            	{
            	    MismatchedSetException mse = new MismatchedSetException(null,input);
            	    throw mse;
            	}


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "boolean"

    public class searchClause_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "searchClause"
    // C:\\NCql\\NCql.Parser\\NCql.g:73:1: searchClause : ( '(' cqlQuery ')' -> cqlQuery | index relation searchTerm -> ^( SEARCHCLAUSE relation index searchTerm ) | searchTerm -> ^( SEARCHCLAUSE EQUAL SERVERCHOICE searchTerm ) );
    public NCqlParser.searchClause_return searchClause() // throws RecognitionException [1]
    {   
        NCqlParser.searchClause_return retval = new NCqlParser.searchClause_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken char_literal25 = null;
        IToken char_literal27 = null;
        NCqlParser.cqlQuery_return cqlQuery26 = null;

        NCqlParser.index_return index28 = null;

        NCqlParser.relation_return relation29 = null;

        NCqlParser.searchTerm_return searchTerm30 = null;

        NCqlParser.searchTerm_return searchTerm31 = null;


        CommonTree char_literal25_tree=null;
        CommonTree char_literal27_tree=null;
        RewriteRuleTokenStream stream_26 = new RewriteRuleTokenStream(adaptor,"token 26");
        RewriteRuleTokenStream stream_27 = new RewriteRuleTokenStream(adaptor,"token 27");
        RewriteRuleSubtreeStream stream_index = new RewriteRuleSubtreeStream(adaptor,"rule index");
        RewriteRuleSubtreeStream stream_cqlQuery = new RewriteRuleSubtreeStream(adaptor,"rule cqlQuery");
        RewriteRuleSubtreeStream stream_searchTerm = new RewriteRuleSubtreeStream(adaptor,"rule searchTerm");
        RewriteRuleSubtreeStream stream_relation = new RewriteRuleSubtreeStream(adaptor,"rule relation");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:73:13: ( '(' cqlQuery ')' -> cqlQuery | index relation searchTerm -> ^( SEARCHCLAUSE relation index searchTerm ) | searchTerm -> ^( SEARCHCLAUSE EQUAL SERVERCHOICE searchTerm ) )
            int alt9 = 3;
            alt9 = dfa9.Predict(input);
            switch (alt9) 
            {
                case 1 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:74:3: '(' cqlQuery ')'
                    {
                    	char_literal25=(IToken)Match(input,26,FOLLOW_26_in_searchClause277);  
                    	stream_26.Add(char_literal25);

                    	PushFollow(FOLLOW_cqlQuery_in_searchClause279);
                    	cqlQuery26 = cqlQuery();
                    	state.followingStackPointer--;

                    	stream_cqlQuery.Add(cqlQuery26.Tree);
                    	char_literal27=(IToken)Match(input,27,FOLLOW_27_in_searchClause281);  
                    	stream_27.Add(char_literal27);



                    	// AST REWRITE
                    	// elements:          cqlQuery
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 74:19: -> cqlQuery
                    	{
                    	    adaptor.AddChild(root_0, stream_cqlQuery.NextTree());

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;
                case 2 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:75:4: index relation searchTerm
                    {
                    	PushFollow(FOLLOW_index_in_searchClause291);
                    	index28 = index();
                    	state.followingStackPointer--;

                    	stream_index.Add(index28.Tree);
                    	PushFollow(FOLLOW_relation_in_searchClause293);
                    	relation29 = relation();
                    	state.followingStackPointer--;

                    	stream_relation.Add(relation29.Tree);
                    	PushFollow(FOLLOW_searchTerm_in_searchClause295);
                    	searchTerm30 = searchTerm();
                    	state.followingStackPointer--;

                    	stream_searchTerm.Add(searchTerm30.Tree);


                    	// AST REWRITE
                    	// elements:          relation, index, searchTerm
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 75:30: -> ^( SEARCHCLAUSE relation index searchTerm )
                    	{
                    	    // C:\\NCql\\NCql.Parser\\NCql.g:75:33: ^( SEARCHCLAUSE relation index searchTerm )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SEARCHCLAUSE, "SEARCHCLAUSE"), root_1);

                    	    adaptor.AddChild(root_1, stream_relation.NextTree());
                    	    adaptor.AddChild(root_1, stream_index.NextTree());
                    	    adaptor.AddChild(root_1, stream_searchTerm.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;
                case 3 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:76:4: searchTerm
                    {
                    	PushFollow(FOLLOW_searchTerm_in_searchClause313);
                    	searchTerm31 = searchTerm();
                    	state.followingStackPointer--;

                    	stream_searchTerm.Add(searchTerm31.Tree);


                    	// AST REWRITE
                    	// elements:          searchTerm
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 76:15: -> ^( SEARCHCLAUSE EQUAL SERVERCHOICE searchTerm )
                    	{
                    	    // C:\\NCql\\NCql.Parser\\NCql.g:76:18: ^( SEARCHCLAUSE EQUAL SERVERCHOICE searchTerm )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SEARCHCLAUSE, "SEARCHCLAUSE"), root_1);

                    	    adaptor.AddChild(root_1, (CommonTree)adaptor.Create(EQUAL, "EQUAL"));
                    	    adaptor.AddChild(root_1, (CommonTree)adaptor.Create(SERVERCHOICE, "SERVERCHOICE"));
                    	    adaptor.AddChild(root_1, stream_searchTerm.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "searchClause"

    public class relation_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "relation"
    // C:\\NCql\\NCql.Parser\\NCql.g:78:1: relation : comparitor ( modifierList )? ;
    public NCqlParser.relation_return relation() // throws RecognitionException [1]
    {   
        NCqlParser.relation_return retval = new NCqlParser.relation_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.comparitor_return comparitor32 = null;

        NCqlParser.modifierList_return modifierList33 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:78:9: ( comparitor ( modifierList )? )
            // C:\\NCql\\NCql.Parser\\NCql.g:79:3: comparitor ( modifierList )?
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_comparitor_in_relation337);
            	comparitor32 = comparitor();
            	state.followingStackPointer--;

            	root_0 = (CommonTree)adaptor.BecomeRoot(comparitor32.Tree, root_0);
            	// C:\\NCql\\NCql.Parser\\NCql.g:79:15: ( modifierList )?
            	int alt10 = 2;
            	int LA10_0 = input.LA(1);

            	if ( (LA10_0 == 33) )
            	{
            	    alt10 = 1;
            	}
            	switch (alt10) 
            	{
            	    case 1 :
            	        // C:\\NCql\\NCql.Parser\\NCql.g:79:16: modifierList
            	        {
            	        	PushFollow(FOLLOW_modifierList_in_relation341);
            	        	modifierList33 = modifierList();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, modifierList33.Tree);

            	        }
            	        break;

            	}


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "relation"

    public class comparitor_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "comparitor"
    // C:\\NCql\\NCql.Parser\\NCql.g:81:1: comparitor : ( comparitorSymbol | namedComparitor );
    public NCqlParser.comparitor_return comparitor() // throws RecognitionException [1]
    {   
        NCqlParser.comparitor_return retval = new NCqlParser.comparitor_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.comparitorSymbol_return comparitorSymbol34 = null;

        NCqlParser.namedComparitor_return namedComparitor35 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:81:11: ( comparitorSymbol | namedComparitor )
            int alt11 = 2;
            int LA11_0 = input.LA(1);

            if ( (LA11_0 == EQUAL || LA11_0 == 21 || (LA11_0 >= 28 && LA11_0 <= 32)) )
            {
                alt11 = 1;
            }
            else if ( ((LA11_0 >= CHARSTRING1 && LA11_0 <= CHARSTRING2)) )
            {
                alt11 = 2;
            }
            else 
            {
                NoViableAltException nvae_d11s0 =
                    new NoViableAltException("", 11, 0, input);

                throw nvae_d11s0;
            }
            switch (alt11) 
            {
                case 1 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:82:2: comparitorSymbol
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_comparitorSymbol_in_comparitor354);
                    	comparitorSymbol34 = comparitorSymbol();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, comparitorSymbol34.Tree);

                    }
                    break;
                case 2 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:83:2: namedComparitor
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_namedComparitor_in_comparitor359);
                    	namedComparitor35 = namedComparitor();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, namedComparitor35.Tree);

                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "comparitor"

    public class comparitorSymbol_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "comparitorSymbol"
    // C:\\NCql\\NCql.Parser\\NCql.g:85:1: comparitorSymbol : ( '=' | '>' | '<' | '>=' | '<=' | '<>' | '==' );
    public NCqlParser.comparitorSymbol_return comparitorSymbol() // throws RecognitionException [1]
    {   
        NCqlParser.comparitorSymbol_return retval = new NCqlParser.comparitorSymbol_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken set36 = null;

        CommonTree set36_tree=null;

        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:85:17: ( '=' | '>' | '<' | '>=' | '<=' | '<>' | '==' )
            // C:\\NCql\\NCql.Parser\\NCql.g:
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	set36 = (IToken)input.LT(1);
            	if ( input.LA(1) == EQUAL || input.LA(1) == 21 || (input.LA(1) >= 28 && input.LA(1) <= 32) ) 
            	{
            	    input.Consume();
            	    adaptor.AddChild(root_0, (CommonTree)adaptor.Create(set36));
            	    state.errorRecovery = false;
            	}
            	else 
            	{
            	    MismatchedSetException mse = new MismatchedSetException(null,input);
            	    throw mse;
            	}


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "comparitorSymbol"

    public class namedComparitor_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "namedComparitor"
    // C:\\NCql\\NCql.Parser\\NCql.g:94:1: namedComparitor : identifier ;
    public NCqlParser.namedComparitor_return namedComparitor() // throws RecognitionException [1]
    {   
        NCqlParser.namedComparitor_return retval = new NCqlParser.namedComparitor_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.identifier_return identifier37 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:94:16: ( identifier )
            // C:\\NCql\\NCql.Parser\\NCql.g:95:2: identifier
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_identifier_in_namedComparitor408);
            	identifier37 = identifier();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, identifier37.Tree);

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "namedComparitor"

    public class modifierList_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "modifierList"
    // C:\\NCql\\NCql.Parser\\NCql.g:97:1: modifierList : ( modifier )+ -> ^( MODIFIERLIST ( modifier )+ ) ;
    public NCqlParser.modifierList_return modifierList() // throws RecognitionException [1]
    {   
        NCqlParser.modifierList_return retval = new NCqlParser.modifierList_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.modifier_return modifier38 = null;


        RewriteRuleSubtreeStream stream_modifier = new RewriteRuleSubtreeStream(adaptor,"rule modifier");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:97:13: ( ( modifier )+ -> ^( MODIFIERLIST ( modifier )+ ) )
            // C:\\NCql\\NCql.Parser\\NCql.g:98:2: ( modifier )+
            {
            	// C:\\NCql\\NCql.Parser\\NCql.g:98:2: ( modifier )+
            	int cnt12 = 0;
            	do 
            	{
            	    int alt12 = 2;
            	    int LA12_0 = input.LA(1);

            	    if ( (LA12_0 == 33) )
            	    {
            	        alt12 = 1;
            	    }


            	    switch (alt12) 
            		{
            			case 1 :
            			    // C:\\NCql\\NCql.Parser\\NCql.g:98:2: modifier
            			    {
            			    	PushFollow(FOLLOW_modifier_in_modifierList417);
            			    	modifier38 = modifier();
            			    	state.followingStackPointer--;

            			    	stream_modifier.Add(modifier38.Tree);

            			    }
            			    break;

            			default:
            			    if ( cnt12 >= 1 ) goto loop12;
            		            EarlyExitException eee12 =
            		                new EarlyExitException(12, input);
            		            throw eee12;
            	    }
            	    cnt12++;
            	} while (true);

            	loop12:
            		;	// Stops C# compiler whining that label 'loop12' has no statements



            	// AST REWRITE
            	// elements:          modifier
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 98:12: -> ^( MODIFIERLIST ( modifier )+ )
            	{
            	    // C:\\NCql\\NCql.Parser\\NCql.g:98:15: ^( MODIFIERLIST ( modifier )+ )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(MODIFIERLIST, "MODIFIERLIST"), root_1);

            	    if ( !(stream_modifier.HasNext()) ) {
            	        throw new RewriteEarlyExitException();
            	    }
            	    while ( stream_modifier.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_modifier.NextTree());

            	    }
            	    stream_modifier.Reset();

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "modifierList"

    public class modifier_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "modifier"
    // C:\\NCql\\NCql.Parser\\NCql.g:100:1: modifier : '/' modifierName ( comparitorSymbol modifierValue )? -> ^( MODIFIER modifierName ( comparitorSymbol modifierValue )? ) ;
    public NCqlParser.modifier_return modifier() // throws RecognitionException [1]
    {   
        NCqlParser.modifier_return retval = new NCqlParser.modifier_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken char_literal39 = null;
        NCqlParser.modifierName_return modifierName40 = null;

        NCqlParser.comparitorSymbol_return comparitorSymbol41 = null;

        NCqlParser.modifierValue_return modifierValue42 = null;


        CommonTree char_literal39_tree=null;
        RewriteRuleTokenStream stream_33 = new RewriteRuleTokenStream(adaptor,"token 33");
        RewriteRuleSubtreeStream stream_modifierName = new RewriteRuleSubtreeStream(adaptor,"rule modifierName");
        RewriteRuleSubtreeStream stream_comparitorSymbol = new RewriteRuleSubtreeStream(adaptor,"rule comparitorSymbol");
        RewriteRuleSubtreeStream stream_modifierValue = new RewriteRuleSubtreeStream(adaptor,"rule modifierValue");
        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:100:9: ( '/' modifierName ( comparitorSymbol modifierValue )? -> ^( MODIFIER modifierName ( comparitorSymbol modifierValue )? ) )
            // C:\\NCql\\NCql.Parser\\NCql.g:101:3: '/' modifierName ( comparitorSymbol modifierValue )?
            {
            	char_literal39=(IToken)Match(input,33,FOLLOW_33_in_modifier438);  
            	stream_33.Add(char_literal39);

            	PushFollow(FOLLOW_modifierName_in_modifier440);
            	modifierName40 = modifierName();
            	state.followingStackPointer--;

            	stream_modifierName.Add(modifierName40.Tree);
            	// C:\\NCql\\NCql.Parser\\NCql.g:101:20: ( comparitorSymbol modifierValue )?
            	int alt13 = 2;
            	int LA13_0 = input.LA(1);

            	if ( (LA13_0 == EQUAL || LA13_0 == 21 || (LA13_0 >= 28 && LA13_0 <= 32)) )
            	{
            	    alt13 = 1;
            	}
            	switch (alt13) 
            	{
            	    case 1 :
            	        // C:\\NCql\\NCql.Parser\\NCql.g:101:21: comparitorSymbol modifierValue
            	        {
            	        	PushFollow(FOLLOW_comparitorSymbol_in_modifier443);
            	        	comparitorSymbol41 = comparitorSymbol();
            	        	state.followingStackPointer--;

            	        	stream_comparitorSymbol.Add(comparitorSymbol41.Tree);
            	        	PushFollow(FOLLOW_modifierValue_in_modifier445);
            	        	modifierValue42 = modifierValue();
            	        	state.followingStackPointer--;

            	        	stream_modifierValue.Add(modifierValue42.Tree);

            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          modifierValue, comparitorSymbol, modifierName
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 101:54: -> ^( MODIFIER modifierName ( comparitorSymbol modifierValue )? )
            	{
            	    // C:\\NCql\\NCql.Parser\\NCql.g:101:57: ^( MODIFIER modifierName ( comparitorSymbol modifierValue )? )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(MODIFIER, "MODIFIER"), root_1);

            	    adaptor.AddChild(root_1, stream_modifierName.NextTree());
            	    // C:\\NCql\\NCql.Parser\\NCql.g:101:81: ( comparitorSymbol modifierValue )?
            	    if ( stream_modifierValue.HasNext() || stream_comparitorSymbol.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_comparitorSymbol.NextTree());
            	        adaptor.AddChild(root_1, stream_modifierValue.NextTree());

            	    }
            	    stream_modifierValue.Reset();
            	    stream_comparitorSymbol.Reset();

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "modifier"

    public class prefix_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "prefix"
    // C:\\NCql\\NCql.Parser\\NCql.g:103:1: prefix : term ;
    public NCqlParser.prefix_return prefix() // throws RecognitionException [1]
    {   
        NCqlParser.prefix_return retval = new NCqlParser.prefix_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.term_return term43 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:103:7: ( term )
            // C:\\NCql\\NCql.Parser\\NCql.g:104:2: term
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_term_in_prefix473);
            	term43 = term();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, term43.Tree);

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "prefix"

    public class uri_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "uri"
    // C:\\NCql\\NCql.Parser\\NCql.g:106:1: uri : term ;
    public NCqlParser.uri_return uri() // throws RecognitionException [1]
    {   
        NCqlParser.uri_return retval = new NCqlParser.uri_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.term_return term44 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:106:4: ( term )
            // C:\\NCql\\NCql.Parser\\NCql.g:107:2: term
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_term_in_uri482);
            	term44 = term();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, term44.Tree);

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "uri"

    public class modifierName_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "modifierName"
    // C:\\NCql\\NCql.Parser\\NCql.g:109:1: modifierName : term ;
    public NCqlParser.modifierName_return modifierName() // throws RecognitionException [1]
    {   
        NCqlParser.modifierName_return retval = new NCqlParser.modifierName_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.term_return term45 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:109:13: ( term )
            // C:\\NCql\\NCql.Parser\\NCql.g:110:2: term
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_term_in_modifierName491);
            	term45 = term();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, term45.Tree);

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "modifierName"

    public class modifierValue_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "modifierValue"
    // C:\\NCql\\NCql.Parser\\NCql.g:112:1: modifierValue : term ;
    public NCqlParser.modifierValue_return modifierValue() // throws RecognitionException [1]
    {   
        NCqlParser.modifierValue_return retval = new NCqlParser.modifierValue_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.term_return term46 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:112:14: ( term )
            // C:\\NCql\\NCql.Parser\\NCql.g:113:2: term
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_term_in_modifierValue500);
            	term46 = term();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, term46.Tree);

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "modifierValue"

    public class searchTerm_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "searchTerm"
    // C:\\NCql\\NCql.Parser\\NCql.g:115:1: searchTerm : term ;
    public NCqlParser.searchTerm_return searchTerm() // throws RecognitionException [1]
    {   
        NCqlParser.searchTerm_return retval = new NCqlParser.searchTerm_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.term_return term47 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:115:11: ( term )
            // C:\\NCql\\NCql.Parser\\NCql.g:116:2: term
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_term_in_searchTerm509);
            	term47 = term();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, term47.Tree);

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "searchTerm"

    public class index_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "index"
    // C:\\NCql\\NCql.Parser\\NCql.g:118:1: index : term ;
    public NCqlParser.index_return index() // throws RecognitionException [1]
    {   
        NCqlParser.index_return retval = new NCqlParser.index_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        NCqlParser.term_return term48 = null;



        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:118:6: ( term )
            // C:\\NCql\\NCql.Parser\\NCql.g:119:2: term
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_term_in_index518);
            	term48 = term();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, term48.Tree);

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "index"

    public class term_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "term"
    // C:\\NCql\\NCql.Parser\\NCql.g:121:1: term : ( identifier | 'and' | 'or' | 'not' | 'prox' | 'sortby' );
    public NCqlParser.term_return term() // throws RecognitionException [1]
    {   
        NCqlParser.term_return retval = new NCqlParser.term_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken string_literal50 = null;
        IToken string_literal51 = null;
        IToken string_literal52 = null;
        IToken string_literal53 = null;
        IToken string_literal54 = null;
        NCqlParser.identifier_return identifier49 = null;


        CommonTree string_literal50_tree=null;
        CommonTree string_literal51_tree=null;
        CommonTree string_literal52_tree=null;
        CommonTree string_literal53_tree=null;
        CommonTree string_literal54_tree=null;

        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:121:5: ( identifier | 'and' | 'or' | 'not' | 'prox' | 'sortby' )
            int alt14 = 6;
            switch ( input.LA(1) ) 
            {
            case CHARSTRING1:
            case CHARSTRING2:
            	{
                alt14 = 1;
                }
                break;
            case 22:
            	{
                alt14 = 2;
                }
                break;
            case 23:
            	{
                alt14 = 3;
                }
                break;
            case 24:
            	{
                alt14 = 4;
                }
                break;
            case 25:
            	{
                alt14 = 5;
                }
                break;
            case 20:
            	{
                alt14 = 6;
                }
                break;
            	default:
            	    NoViableAltException nvae_d14s0 =
            	        new NoViableAltException("", 14, 0, input);

            	    throw nvae_d14s0;
            }

            switch (alt14) 
            {
                case 1 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:122:2: identifier
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_identifier_in_term527);
                    	identifier49 = identifier();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, identifier49.Tree);

                    }
                    break;
                case 2 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:123:2: 'and'
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	string_literal50=(IToken)Match(input,22,FOLLOW_22_in_term532); 
                    		string_literal50_tree = (CommonTree)adaptor.Create(string_literal50);
                    		adaptor.AddChild(root_0, string_literal50_tree);


                    }
                    break;
                case 3 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:124:2: 'or'
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	string_literal51=(IToken)Match(input,23,FOLLOW_23_in_term537); 
                    		string_literal51_tree = (CommonTree)adaptor.Create(string_literal51);
                    		adaptor.AddChild(root_0, string_literal51_tree);


                    }
                    break;
                case 4 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:125:2: 'not'
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	string_literal52=(IToken)Match(input,24,FOLLOW_24_in_term542); 
                    		string_literal52_tree = (CommonTree)adaptor.Create(string_literal52);
                    		adaptor.AddChild(root_0, string_literal52_tree);


                    }
                    break;
                case 5 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:126:2: 'prox'
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	string_literal53=(IToken)Match(input,25,FOLLOW_25_in_term546); 
                    		string_literal53_tree = (CommonTree)adaptor.Create(string_literal53);
                    		adaptor.AddChild(root_0, string_literal53_tree);


                    }
                    break;
                case 6 :
                    // C:\\NCql\\NCql.Parser\\NCql.g:127:2: 'sortby'
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	string_literal54=(IToken)Match(input,20,FOLLOW_20_in_term551); 
                    		string_literal54_tree = (CommonTree)adaptor.Create(string_literal54);
                    		adaptor.AddChild(root_0, string_literal54_tree);


                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "term"

    public class identifier_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "identifier"
    // C:\\NCql\\NCql.Parser\\NCql.g:129:1: identifier : ( CHARSTRING1 | CHARSTRING2 );
    public NCqlParser.identifier_return identifier() // throws RecognitionException [1]
    {   
        NCqlParser.identifier_return retval = new NCqlParser.identifier_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken set55 = null;

        CommonTree set55_tree=null;

        try 
    	{
            // C:\\NCql\\NCql.Parser\\NCql.g:129:11: ( CHARSTRING1 | CHARSTRING2 )
            // C:\\NCql\\NCql.Parser\\NCql.g:
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	set55 = (IToken)input.LT(1);
            	if ( (input.LA(1) >= CHARSTRING1 && input.LA(1) <= CHARSTRING2) ) 
            	{
            	    input.Consume();
            	    adaptor.AddChild(root_0, (CommonTree)adaptor.Create(set55));
            	    state.errorRecovery = false;
            	}
            	else 
            	{
            	    MismatchedSetException mse = new MismatchedSetException(null,input);
            	    throw mse;
            	}


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "identifier"

    // Delegated rules


   	protected DFA6 dfa6;
   	protected DFA9 dfa9;
	private void InitializeCyclicDFAs()
	{
    	this.dfa6 = new DFA6(this);
    	this.dfa9 = new DFA9(this);


	}

    const string DFA6_eotS =
        "\x0a\uffff";
    const string DFA6_eofS =
        "\x0a\uffff";
    const string DFA6_minS =
        "\x01\x15\x07\x04\x02\uffff";
    const string DFA6_maxS =
        "\x01\x15\x01\x19\x06\x1a\x02\uffff";
    const string DFA6_acceptS =
        "\x08\uffff\x01\x02\x01\x01";
    const string DFA6_specialS =
        "\x0a\uffff}>";
    static readonly string[] DFA6_transitionS = {
            "\x01\x01",
            "\x02\x02\x0e\uffff\x01\x07\x01\uffff\x01\x03\x01\x04\x01\x05"+
            "\x01\x06",
            "\x02\x08\x01\uffff\x01\x09\x0c\uffff\x07\x08",
            "\x02\x08\x01\uffff\x01\x09\x0c\uffff\x07\x08",
            "\x02\x08\x01\uffff\x01\x09\x0c\uffff\x07\x08",
            "\x02\x08\x01\uffff\x01\x09\x0c\uffff\x07\x08",
            "\x02\x08\x01\uffff\x01\x09\x0c\uffff\x07\x08",
            "\x02\x08\x01\uffff\x01\x09\x0c\uffff\x07\x08",
            "",
            ""
    };

    static readonly short[] DFA6_eot = DFA.UnpackEncodedString(DFA6_eotS);
    static readonly short[] DFA6_eof = DFA.UnpackEncodedString(DFA6_eofS);
    static readonly char[] DFA6_min = DFA.UnpackEncodedStringToUnsignedChars(DFA6_minS);
    static readonly char[] DFA6_max = DFA.UnpackEncodedStringToUnsignedChars(DFA6_maxS);
    static readonly short[] DFA6_accept = DFA.UnpackEncodedString(DFA6_acceptS);
    static readonly short[] DFA6_special = DFA.UnpackEncodedString(DFA6_specialS);
    static readonly short[][] DFA6_transition = DFA.UnpackEncodedStringArray(DFA6_transitionS);

    protected class DFA6 : DFA
    {
        public DFA6(BaseRecognizer recognizer)
        {
            this.recognizer = recognizer;
            this.decisionNumber = 6;
            this.eot = DFA6_eot;
            this.eof = DFA6_eof;
            this.min = DFA6_min;
            this.max = DFA6_max;
            this.accept = DFA6_accept;
            this.special = DFA6_special;
            this.transition = DFA6_transition;

        }

        override public string Description
        {
            get { return "55:1: prefixAssignment : ( '>' prefix '=' uri -> ^( PREFIX uri prefix ) | '>' uri -> ^( PREFIX uri ) );"; }
        }

    }

    const string DFA9_eotS =
        "\x0a\uffff";
    const string DFA9_eofS =
        "\x02\uffff\x06\x08\x02\uffff";
    const string DFA9_minS =
        "\x01\x04\x01\uffff\x06\x04\x02\uffff";
    const string DFA9_maxS =
        "\x01\x1a\x01\uffff\x06\x20\x02\uffff";
    const string DFA9_acceptS =
        "\x01\uffff\x01\x01\x06\uffff\x01\x03\x01\x02";
    const string DFA9_specialS =
        "\x0a\uffff}>";
    static readonly string[] DFA9_transitionS = {
            "\x02\x02\x0e\uffff\x01\x07\x01\uffff\x01\x03\x01\x04\x01\x05"+
            "\x01\x06\x01\x01",
            "",
            "\x02\x09\x01\uffff\x01\x09\x0c\uffff\x01\x08\x01\x09\x04\x08"+
            "\x01\uffff\x01\x08\x05\x09",
            "\x02\x09\x01\uffff\x01\x09\x0c\uffff\x01\x08\x01\x09\x04\x08"+
            "\x01\uffff\x01\x08\x05\x09",
            "\x02\x09\x01\uffff\x01\x09\x0c\uffff\x01\x08\x01\x09\x04\x08"+
            "\x01\uffff\x01\x08\x05\x09",
            "\x02\x09\x01\uffff\x01\x09\x0c\uffff\x01\x08\x01\x09\x04\x08"+
            "\x01\uffff\x01\x08\x05\x09",
            "\x02\x09\x01\uffff\x01\x09\x0c\uffff\x01\x08\x01\x09\x04\x08"+
            "\x01\uffff\x01\x08\x05\x09",
            "\x02\x09\x01\uffff\x01\x09\x0c\uffff\x01\x08\x01\x09\x04\x08"+
            "\x01\uffff\x01\x08\x05\x09",
            "",
            ""
    };

    static readonly short[] DFA9_eot = DFA.UnpackEncodedString(DFA9_eotS);
    static readonly short[] DFA9_eof = DFA.UnpackEncodedString(DFA9_eofS);
    static readonly char[] DFA9_min = DFA.UnpackEncodedStringToUnsignedChars(DFA9_minS);
    static readonly char[] DFA9_max = DFA.UnpackEncodedStringToUnsignedChars(DFA9_maxS);
    static readonly short[] DFA9_accept = DFA.UnpackEncodedString(DFA9_acceptS);
    static readonly short[] DFA9_special = DFA.UnpackEncodedString(DFA9_specialS);
    static readonly short[][] DFA9_transition = DFA.UnpackEncodedStringArray(DFA9_transitionS);

    protected class DFA9 : DFA
    {
        public DFA9(BaseRecognizer recognizer)
        {
            this.recognizer = recognizer;
            this.decisionNumber = 9;
            this.eot = DFA9_eot;
            this.eof = DFA9_eof;
            this.min = DFA9_min;
            this.max = DFA9_max;
            this.accept = DFA9_accept;
            this.special = DFA9_special;
            this.transition = DFA9_transition;

        }

        override public string Description
        {
            get { return "73:1: searchClause : ( '(' cqlQuery ')' -> cqlQuery | index relation searchTerm -> ^( SEARCHCLAUSE relation index searchTerm ) | searchTerm -> ^( SEARCHCLAUSE EQUAL SERVERCHOICE searchTerm ) );"; }
        }

    }

 

    public static readonly BitSet FOLLOW_sortedQuery_in_q42 = new BitSet(new ulong[]{0x0000000000000000UL});
    public static readonly BitSet FOLLOW_EOF_in_q44 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_prefixAssignment_in_sortedQuery60 = new BitSet(new ulong[]{0x0000000007F00030UL});
    public static readonly BitSet FOLLOW_scopedClause_in_sortedQuery63 = new BitSet(new ulong[]{0x0000000000100002UL});
    public static readonly BitSet FOLLOW_20_in_sortedQuery66 = new BitSet(new ulong[]{0x0000000003D00030UL});
    public static readonly BitSet FOLLOW_sortSpec_in_sortedQuery68 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_singleSpec_in_sortSpec106 = new BitSet(new ulong[]{0x0000000003D00032UL});
    public static readonly BitSet FOLLOW_index_in_singleSpec116 = new BitSet(new ulong[]{0x0000000200000002UL});
    public static readonly BitSet FOLLOW_modifierList_in_singleSpec118 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_prefixAssignment_in_cqlQuery142 = new BitSet(new ulong[]{0x0000000007F00030UL});
    public static readonly BitSet FOLLOW_cqlQuery_in_cqlQuery144 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_scopedClause_in_cqlQuery150 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_21_in_prefixAssignment161 = new BitSet(new ulong[]{0x0000000003D00030UL});
    public static readonly BitSet FOLLOW_prefix_in_prefixAssignment163 = new BitSet(new ulong[]{0x0000000000000080UL});
    public static readonly BitSet FOLLOW_EQUAL_in_prefixAssignment165 = new BitSet(new ulong[]{0x0000000003D00030UL});
    public static readonly BitSet FOLLOW_uri_in_prefixAssignment167 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_21_in_prefixAssignment183 = new BitSet(new ulong[]{0x0000000003D00030UL});
    public static readonly BitSet FOLLOW_uri_in_prefixAssignment185 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_searchClause_in_scopedClause206 = new BitSet(new ulong[]{0x0000000003C00002UL});
    public static readonly BitSet FOLLOW_booleanGroup_in_scopedClause209 = new BitSet(new ulong[]{0x0000000007D00030UL});
    public static readonly BitSet FOLLOW_searchClause_in_scopedClause212 = new BitSet(new ulong[]{0x0000000003C00002UL});
    public static readonly BitSet FOLLOW_boolean_in_booleanGroup223 = new BitSet(new ulong[]{0x0000000200000002UL});
    public static readonly BitSet FOLLOW_modifierList_in_booleanGroup226 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_set_in_boolean0 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_26_in_searchClause277 = new BitSet(new ulong[]{0x0000000007F00030UL});
    public static readonly BitSet FOLLOW_cqlQuery_in_searchClause279 = new BitSet(new ulong[]{0x0000000008000000UL});
    public static readonly BitSet FOLLOW_27_in_searchClause281 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_index_in_searchClause291 = new BitSet(new ulong[]{0x00000001F02000B0UL});
    public static readonly BitSet FOLLOW_relation_in_searchClause293 = new BitSet(new ulong[]{0x0000000007D00030UL});
    public static readonly BitSet FOLLOW_searchTerm_in_searchClause295 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_searchTerm_in_searchClause313 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_comparitor_in_relation337 = new BitSet(new ulong[]{0x0000000200000002UL});
    public static readonly BitSet FOLLOW_modifierList_in_relation341 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_comparitorSymbol_in_comparitor354 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_namedComparitor_in_comparitor359 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_set_in_comparitorSymbol0 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_identifier_in_namedComparitor408 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_modifier_in_modifierList417 = new BitSet(new ulong[]{0x0000000200000002UL});
    public static readonly BitSet FOLLOW_33_in_modifier438 = new BitSet(new ulong[]{0x0000000003D00030UL});
    public static readonly BitSet FOLLOW_modifierName_in_modifier440 = new BitSet(new ulong[]{0x00000001F0200082UL});
    public static readonly BitSet FOLLOW_comparitorSymbol_in_modifier443 = new BitSet(new ulong[]{0x0000000003D00030UL});
    public static readonly BitSet FOLLOW_modifierValue_in_modifier445 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_term_in_prefix473 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_term_in_uri482 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_term_in_modifierName491 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_term_in_modifierValue500 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_term_in_searchTerm509 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_term_in_index518 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_identifier_in_term527 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_22_in_term532 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_23_in_term537 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_24_in_term542 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_25_in_term546 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_20_in_term551 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_set_in_identifier0 = new BitSet(new ulong[]{0x0000000000000002UL});

}
